//
//  LSExponentCell.m
//  LookScore
//
//  Created by wws on 2018/3/20.
//  Copyright © 2018年 ChongQingXunTiCompany. All rights reserved.
//

#import "LSExponentCell.h"
#import "LSExponentModel.h"
@interface LSExponentCell()
@property (nonatomic, strong) UIView * bgView;
@property (nonatomic, strong) UILabel * companyLabel;
@property (nonatomic, strong) UIImageView * lineImageView;

@property (nonatomic, strong) UIView * bgView1;
@property (nonatomic, strong) UIView * bgView2;
@property (nonatomic, strong) UILabel * momentLabel1;
@property (nonatomic, strong) UILabel * momentLabel2;
@property (nonatomic, strong) UILabel * hostScore1;
@property (nonatomic, strong) UILabel * hostScore2;
@property (nonatomic, strong) UILabel * guestScore1;
@property (nonatomic, strong) UILabel * guestScore2;
@property (nonatomic, strong) UILabel * concedePoints1;
@property (nonatomic, strong) UILabel * concedePoints2;



@end


@implementation LSExponentCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}
+ (LSExponentCell *)exponentTableViewCellBytableView:(UITableView *)tableView{
    
    LSExponentCell *cell=[tableView dequeueReusableCellWithIdentifier:NSStringFromClass(self)];
    if (!cell) {
        cell=[[LSExponentCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass(self)];
        cell.selectionStyle=UITableViewCellSelectionStyleNone;
    }
    return cell;
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self addContentView];
    }
    
    return self;
}

- (void)addContentView{
    self.bgView = [[UIView alloc] init];
    [self.contentView addSubview:self.bgView];
    self.bgView.sd_layout.leftEqualToView(self.contentView).topEqualToView(self.contentView).rightEqualToView(self.contentView).bottomEqualToView(self.contentView);
    self.companyLabel = [[UILabel alloc] init];
    self.companyLabel.text = @"sa";
    self.companyLabel.numberOfLines = 2;
    self.companyLabel.textAlignment = NSTextAlignmentCenter;
    self.companyLabel.tintColor = LSTitleGrayColor1;
    self.companyLabel.font = [UIFont systemFontOfSize:12];
    [self.contentView addSubview:self.companyLabel];
    self.companyLabel.sd_layout
    .leftEqualToView(self.bgView)
    .topEqualToView(self.bgView)
    .widthIs(80)
    .heightIs(80);
    
    self.lineImageView = [[UIImageView alloc] init];
    self.lineImageView.backgroundColor = LSSubColorf25e59;
    [self.contentView addSubview:self.lineImageView];
    self.lineImageView.sd_layout.topEqualToView(self.bgView).leftSpaceToView(self.companyLabel, 0).widthIs(1).heightRatioToView(self.companyLabel, 1.0);
    
    self.bgView1 = [[UIView alloc] init];
    self.bgView1.backgroundColor = [UIColor whiteColor];
    [self.contentView addSubview:self.bgView1];
    self.bgView1.sd_layout.leftSpaceToView(self.lineImageView, 0).topEqualToView(self.bgView).rightEqualToView(self.bgView).heightRatioToView(self.lineImageView, 0.5);
    
    self.bgView2 = [[UIView alloc] init];
    self.bgView2.backgroundColor = [UIColor groupTableViewBackgroundColor];
    [self.contentView addSubview:self.bgView2];
    self.bgView2.sd_layout.topSpaceToView(self.bgView1, 0).leftSpaceToView(self.lineImageView, 0).rightEqualToView(self.bgView).heightRatioToView(self.lineImageView, 0.5);
    
    self.momentLabel1 = [[UILabel alloc] init];
    self.momentLabel1.text = @"初始";
    self.momentLabel1.textColor = LSNavMainColor;
    self.momentLabel1.textAlignment = NSTextAlignmentCenter;
    self.momentLabel1.font = [UIFont systemFontOfSize:12];
    [self.bgView1 addSubview:self.momentLabel1];
    self.momentLabel1.sd_layout.leftSpaceToView(self.bgView1, 0).topEqualToView(self.bgView1).heightRatioToView(self.bgView1, 1).widthRatioToView(self.bgView1, 0.25);
    
    self.momentLabel2 = [[UILabel alloc] init];
    self.momentLabel2.text = @"即时";
    self.momentLabel2.textAlignment = NSTextAlignmentCenter;
    self.momentLabel2.textColor = LSSubColorf25e59;
    self.momentLabel2.font = [UIFont systemFontOfSize:12];
    [self.bgView2 addSubview:self.momentLabel2];
   
        self.momentLabel2.sd_layout.leftSpaceToView(self.bgView2, 0).topEqualToView(self.bgView2).heightRatioToView(self.bgView2, 1).widthRatioToView(self.bgView2, 0.25);
    
    self.hostScore1 = [[UILabel alloc] init];
    self.hostScore1.text = @"0.90";
    self.hostScore1.textColor = LSTitleGrayColor2;
    self.hostScore1.textAlignment = NSTextAlignmentCenter;
    self.hostScore1.font = [UIFont systemFontOfSize:12];
    [self.bgView1 addSubview:self.hostScore1];
    self.hostScore1.sd_layout.leftSpaceToView(self.momentLabel1, 0).topEqualToView(self.bgView1).heightRatioToView(self.bgView1, 1).widthRatioToView(self.bgView1, 0.25);
    
    self.hostScore2 = [[UILabel alloc] init];
    self.hostScore2.textColor = LSTitleGrayColor2;
    self.hostScore2.textAlignment = NSTextAlignmentCenter;
    self.hostScore2.font = [UIFont systemFontOfSize:12];
    self.hostScore2.text = @"1.21";
    [self.bgView2 addSubview:self.hostScore2];
    self.hostScore2.sd_layout.topEqualToView(self.bgView2).leftSpaceToView(self.momentLabel2, 0).widthRatioToView(self.bgView2, 0.25).heightRatioToView(self.bgView2, 1);
    
    self.concedePoints1 = [[UILabel alloc] init];
    self.concedePoints1.text = @"七半";
    self.concedePoints1.textColor = LSTitleGrayColor2;
    self.concedePoints1.textAlignment = NSTextAlignmentCenter;
    self.concedePoints1.font = [UIFont systemFontOfSize:12];
    [self.bgView1 addSubview:self.concedePoints1];
    self.concedePoints1.sd_layout.leftSpaceToView(self.hostScore1, 0).topEqualToView(self.bgView1).widthRatioToView(self.bgView1, 0.25).heightRatioToView(self.bgView1, 1);
    
    self.concedePoints2 = [[UILabel alloc] init];
    self.concedePoints2.text = @"七半";
    self.concedePoints2.textAlignment = NSTextAlignmentCenter;
    self.concedePoints2.textColor = LSTitleGrayColor2;
    self.concedePoints2.font = [UIFont systemFontOfSize:12];
    [self.bgView2 addSubview:self.concedePoints2];
    self.concedePoints2.sd_layout.leftSpaceToView(self.hostScore2, 0).topEqualToView(self.bgView2).widthRatioToView(self.bgView2, 0.25).heightRatioToView(self.bgView2, 1);
    
    self.guestScore1 = [[UILabel alloc] init];
    self.guestScore1.text = @"0.86";
    self.guestScore1.textColor = LSTitleGrayColor2;
    self.guestScore1.font = [UIFont systemFontOfSize:12];
    self.guestScore1.textAlignment = NSTextAlignmentCenter;
    [self.bgView1 addSubview:self.guestScore1];
    self.guestScore1.sd_layout.topEqualToView(self.bgView1).leftSpaceToView(self.concedePoints1, 0).heightRatioToView(self.bgView1, 1).widthRatioToView(self.bgView1, 0.25);
    
    self.guestScore2 = [[UILabel alloc] init];
    self.guestScore2.text = @"0.72";
    self.guestScore2.textColor = LSTitleGrayColor2;
    self.guestScore2.font = [UIFont systemFontOfSize:12];
    self.guestScore2.textAlignment = NSTextAlignmentCenter;
    [self.bgView2 addSubview:self.guestScore2];
    self.guestScore2.sd_layout.topEqualToView(self.bgView2).leftSpaceToView(self.concedePoints2, 0).heightRatioToView(self.bgView2, 1).widthRatioToView(self.bgView2, 0.25);
    
    
}

- (void)setOddModel:(OddsChangeRecordList *)oddModel{
    _oddModel = oddModel;
    
    _companyLabel.text = oddModel.CompanyName;
    companyData * data = oddModel.companyData.firstObject;
    self.hostScore2.text = data.Odds_Win;
    self.concedePoints2.text = data.Odds_Flat;
    self.guestScore2.text = data.Odds_Negative;
    companyData * data1 = oddModel.companyData.lastObject;
    self.hostScore1.text = data1.Odds_Win;
    self.concedePoints1.text = data1.Odds_Flat;
    self.guestScore1.text = data1.Odds_Negative;
    
}

- (void)setModel:(AIHistoricaDataList *)model{
    
    _model = model;
    
    _companyLabel.text = model.CompanyName;
    
    NSArray * dataArray = model.companyData;
    if (dataArray.count > 1) {
        for (companyData * data in model.companyData) {
            if (data.State == 0){
                self.hostScore1.text = data.HD_ZD;
                self.concedePoints1.text = data.HD_PK;
                self.guestScore1.text = data.HD_KD;
            }
        }
        
        companyData * data = dataArray.firstObject;
        self.hostScore2.text = data.HD_ZD;
        self.concedePoints2.text = data.HD_PK;
        self.guestScore2.text = data.HD_KD;
    }else if(dataArray.count == 1){
        
        companyData * data = dataArray.firstObject;
        self.hostScore1.text = data.HD_ZD;
        self.concedePoints1.text = data.HD_PK;
        self.guestScore1.text = data.HD_KD;
        
        
        self.hostScore2.text = @"-";
        self.concedePoints2.text = @"-";
        self.guestScore2.text = @"-";
        
    }else{
        self.hostScore1.text = @"-";
        self.concedePoints1.text = @"-";
        self.guestScore1.text = @"-";
        
        
        self.hostScore2.text = @"-";
        self.concedePoints2.text = @"-";
        self.guestScore2.text = @"-";
        
    }
}


- (void)setSdModel:(SDHistoricaDataList *)sdModel{
    _sdModel = sdModel;
    _companyLabel.text = sdModel.CompanyName;
    NSArray * dataArray = sdModel.companyData;
    if (dataArray.count > 1) {
        for (companyData * data in sdModel.companyData) {
             if (data.State == 0){
                self.hostScore1.text = data.HD_DQ;
                self.concedePoints1.text = data.HD_PK;
                self.guestScore1.text = data.HD_XQ;
            }
        }
        companyData * data = dataArray.firstObject;
        self.hostScore2.text = data.HD_DQ;
        self.concedePoints2.text = data.HD_PK;
        self.guestScore2.text = data.HD_XQ;
    }else if(dataArray.count == 1){
        
        companyData * data = dataArray.firstObject;
        self.hostScore1.text = data.HD_ZD;
        self.concedePoints1.text = data.HD_PK;
        self.guestScore1.text = data.HD_KD;
        
        
        self.hostScore2.text = @"-";
        self.concedePoints2.text = @"-";
        self.guestScore2.text = @"-";
        
    }else{
        self.hostScore1.text = @"-";
        self.concedePoints1.text = @"-";
        self.guestScore1.text = @"-";
        
        
        self.hostScore2.text = @"-";
        self.concedePoints2.text = @"-";
        self.guestScore2.text = @"-";
        
    }
//    for (companyData * data in sdModel.companyData) {
//        if (data.State == 1) {
//            self.hostScore1.text = data.HD_ZD;
//            self.concedePoints1.text = data.HD_PK;
//            self.guestScore1.text = data.HD_KD;
//        }else if (data.State == 0){
//            self.hostScore2.text = data.HD_ZD;
//            self.concedePoints2.text = data.HD_PK;
//            self.guestScore2.text = data.HD_KD;
//        }
//    }
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
